An optimal B-spline approach for vectorizing raster image outlines

Capturing outlines is crucial in vectorization of the digital images. An effective and automatic algorithm is presented for outline vectorizing of planar objects within the digital images using trigonometric B-spline. A soft computing optimization technique Genetic Algorithm (GA) is employed to determine the suitable measures of parameter in the description of proposed B-spline. The anticipated scheme is executed on a few raster (bitmap), digital images to validate the robustness of the algorithm. The procedure of vectorizing outlines encompasses a series of stages like boundary detection, corner recognition, break point identification and curve fitting using the proposed B-spline.


Introduction
The majority of computer images are typically in raster format.These images are prevalent due to the fact that nearly all scanners and digital cameras generate raster images.These raster images consist of minuscule dots referred to as pixels, with each pixel representing the color of the image at a specific location.Typically, these pixels are organized in a regular rectangular grid.On the other hand, there exists an alternative image format known as vector format.In contrast to raster images, which are composed of pixels, vector images consist of smoother elements such as lines, polygons, and curves.Furthermore, vector images often occupy less storage space, with the required space being determined by the complexity of the image rather than its size and resolution.Due to the advantages associated with vector images, the ability to convert a raster image into a vector image is highly valuable.This process of conversion is cited to as vectorization.Instead of concentrating on scaling, sharing, and rotational aspects involved in vectorization for these images, the motivation for the proposed work is focused specifically on image outline vectorization.
One of the fundamental features of capturing and vectorizing image outlines entails the modeling and designing of appropriate curve fitting schemes.This stage of dealing with image outlines makes essential significances when addressing real-world applications involving in cartooning, logo designing, font designing, embroidery and textile designing among others.Whereas other stages of the procedure consist of a number of computational and mathematical phases, all of which are usually intended to approximate a curve that closely fits the set of data points.Hence, the long-term objective of this effort is to generate vectorizing outline for planar objects in the image that are both approximately reliable and computationally effective.There are many benefits to using curves to express planar things.While substantial progress has been made in this field through previous research efforts [1][2][3][4][5][6][7][8][9][10][11][12], there remains a desire to delve further into more advanced and interactive strategies.
In this work, an optimal approach for image vectorizing outline is presented, categorically designed to handle the data gathered from the raster (bitmap) image boundaries for planner objects.To achieve optimal curve fitting for image outline, the suggested method uses a freeform trigonometric B-Spline representation and the capabilities of soft computing, specifically the Genetic Algorithm (GA).In this framework, a quadratic trigonometric B-spline has been used, which is defined by a single shape parameter that is introduced in its description.In contrast, GA seeks to identify parameter values that minimize the discrepancy between the fitted spline curve and the observed image boundary.
Trigonometric B-spline as compare to traditional B-splines are more versatile in dealing with curve fitting complex geometrical challenges.In contrast to traditional B-spline, they utilized trigonometric basis functions involving in sine and cosine functions aeeeeeeeeelong a with series of control points.By hiring these trigonometric B-spline curves in vectorization process, the algorithm acquires the ability to accurately capture and flexible representation of curve to complex geometrical shapes and counters presented in raster images.This flexibility enables seamless handling of curves, resulting in better vectorization outcomes particularly when the form displays periodic or wave-like features.
Genetic Algorithms (GAs) have proven to be useful and effective in variety of sectors that deals with optimization challenges.The foundation of these algorithmic techniques is the idea of natural selection and evaluation.By applying GAs to proposed image vectorization procedure, they offer powerful approach to automate and optimized the values of parameters of trigonometric B-splines to get the best suited incoming raster image data.The optimization procedure iteratively modified the control points, basis function and other parameters of trigonometric B-spline curves and enable the generation of high quality vectorized presentation with minimal manual intervention, that helps to reduce the inaccuracy between the newly generated vectorized outline with original one.Cumulatively, use of trigonometric B-spline along with GAs into the proposed vectorization scheme, enhanced the capabilities to capture complex geometric shapes and optimizes the vectorized outline.
The paper is structured as: Section 2 and Section 3 covers the construction and properties of proposed free form trigonometric B-Spline like representation.Section 4 discusses the genetic algorithm, while Section 5 describes the overall proposed approach, including boundary extraction, corner identification, problem matching and curve fitting.Section 6 demonstrates all the pictorial results from iterations when applied to the sample images whereas the comparative and subsequent studies are conducted in Section 7. Finally, the concluding remarks are made in Sections 8.

Curve fitting with Quadratic Trigonometric B-spline (QTB-Spline)
A space of QTB-Spline function with single control parameter is developed by using a constructive approach described in [13].A quadratic trigonometric spline with parameter ω i is built up in Section 2.1 to formulate the above said QTB-Spline followed by the construction of free form trigonometric basis and B-spline like curve modelling in Section 2.2 and Section 2.3 respectively.

Quadratic Trigonometric Spline (QTS)
A Quadratic Trigonometric Spline (QTS) space Ω(Δ), where Δ = (a is put in a space of C 1 trigonometric piecewise polynomials of degree � 2. The QTS space is spanned by the QT basis functions, It can easily be noticed from Eq (1) that the QT basis functions have the similarity to the basis functions of Bernstein Bézier which are demonstrated in Fig 1.

Proposition 1
Th geometric features of the basis functions defined in (1) are as follows: � Partition of Unity : Proof.The above-mentioned characteristics arise directly from the formulation and evolution of the basis function.

Construction of free form trigonometric basis
On the way to The approach of this section is to furnish the trigonometric B-spline free form basis of QTS defined in Section 2.1.For the local function η k (z); k = −1,. ..,n+3 with suggested spline, is defined to construct trigonometric free form basis.Let us take, additional knots ( and for the intervals 3 are defined in the same way as in Eq (6).As per necessity that the function η k is second order continuous at z kÀ 2 ; z kÀ 1 ; z k and z kþ1 , the function η k (z) must satisfied the following: where, Next, the difference of the function η k will be took, for the final expression of free form trigonometric free form basis, as: A definite form of the trigonometric basis function M k (z) on any interval [z i , z i+1 ) is composed by ( 6)-( 8) as: where Proposition 2. The geometric feature of trigonometric free form basis functions ( 9) are as follows: � Partition of unity property : Proof: The above-mentioned characteristics arise directly, from the formulation and growth of the basis function.

B-Spline like curve modelling
To compute the required Quadratic Trigonometric B-spline (QTB-Spline) freeform cure representation, let us defined P*(z) for z2[z 0 , z n ] as: With control points T * k , whose value can be found with help of set of given spatial data points.Furthermore, Eq (13) can be rewritten as: From Eq (9) and Eq (14); where Eq (9) can be reconstructed in vector form as: Now, the transformed Bernstein Be´zier in Eq (16) can easily be used for computational purpose.It's important to highlight that the challenge of QTB-Spline interpolation can be addressed through the following equation, where the diagonal-dominating tridiagonal matrix M j (z j ) is involved: This equation establishes the existence of a unique QTB-Spline as an alternative to Bsplines.Fig 2 provides some examples about the adjustment effect of shape parameters ω i on the QTB-spline curve given in (16), thus the QTB-spline curve shows better approximation ability than classical quadratic Be´zier curves.Proof.Given that from ( 11) and ( 12 Proof.Derived from (15) it becomes evident that both � k , ξ k �0.Furthermore, U k and V k reside on the line that connects L k and L k+1 .As, m k ¼ h k h k À h kÀ 1 and fall within the range 0 < μ k < 1, the following relationship can be expressed as:

Geometric properties of QTB-Spline
Consequently, the control points of QTB-Spline control polygon result in similar way that the polygon of piecewise Bernstein Be´zier do.The QTB-Spline adheres to the variation diminishing property, as this property is satisfied by the the piecewise Bernstein Be´zier curve.

Genetic Algorithm (GA)
GA [14] is a search technique inspired by the natural procedure of evolution.It is employed to generate solutions for optimization problems.In this method, each potential solution within the search space is represented as a bitstring, referred to as a chromosome, with its individual bits being the genes, as shown in Fig 5 .GA commences with a set of potential solutions known as a population.It operates with genetic optimization operators: mutation, selection operator and crossover, in conjunction with a fitness function.The primary aim of the crossover and mutation operators is to create new chromosomes from existing ones, inheriting beneficial traits from their parent chromosomes.The fitness function assesses the quality of each within the population, with higher fitness values increasing the likelihood of selection.
Following the selection of the fittest chromosomes from the mutation, population and crossover, operations are enforced to enhance the fitness values.Before initiating the search, GA randomly selects a collection of chromosomes from the search space, where in our specific problem, the chromosomes represent the shape parameters.Subsequently, optimal operators are executed to generate new offspring, with the anticipation that each new generation will exhibit improved fitness compared to the previous one.Only chosen chromosomes are allowed to reproduce.The iterative application of this algorithm gradually produces the best chromosome, and the process continues until a predefined stopping condition is satisfied, ultimately yielding a solution to the problem.Table 1 provides a list of the GA parameters employed in the proposed scheme.

Implementation strategy
The comprehensive plan for addressing the problem at hand is elaborated upon in this discussion.The entire algorithm is visually depicted in Fig 6 , showcasing the flowchart of the process.
The goal is to establish a curve that optimally matches the data generated by the boundaries of planar objects in images.The proposed approach encompasses several stages, including boundary detection, identification of corner points, curve fitting through the utilization of Genetic Algorithms and the trigonometric B-spline representation (16).

Boundary detection
The process of obtaining the graphical representation of planar objects is initiated by detecting their boundaries.The prevalent method for extracting these boundaries is detailed in [15].This technique operates by taking the image of the object as input and subsequently deriving

Identification of corner points
Corners play a valuable role as they offer a preliminary insight into the configuration of an image.The approach used for corner identification in this paper is expounded in [16], wherein corner intensity is linked with each point along the boundary.The procedure comprises two distinct phases.In the initial phase, it identifies the corners from the entire dataset, while in the second phase, certain criteria are applied to eliminate additional points, retaining only possible corners.The details of these phases provided in [16]   |} + −} − | is the distance between } + and } − .Thus, the opening angle of the triangle, named as ϕ can be determined by using law of cosine: . Subsequently, for each point }, there may exist zero, one or more than one ϕ-values.So that the minimum value of ϕ among all ϕ -values is picked out as ϕ-value of the point }.
Phase 2: In this phase, some additional points are annihilated.A potential corner point } from the initial phase is cast away if it possesses a sharper valid neighboring point } v : ϕ(})>ϕ (} v ).Here, the candidate point Additionally, the corners are of paramount importance as they separate the data into distinct segments.Following the segmentation, the data values can be made up as P i,j = (x i,j , y i,j ); i = 1,2,3,. ..,n and j = 1,2,3,. ...,m i with n denoting the number of segments and m i representing the number of data points in the ith segment.Here, P i,j signifies the jth point within the ith segment.Visually the new detected corners of the boundaries shown in  2 provides information on the number of contour points and the count of detected corner points for sample images.

Problem description
The objective is to generate a curve that closely approximates the original one (the contour), essentially finding suitable parameter values that yield the desired curve outline.The proposed approach effectively transforms the initial continuous problem into a discrete optimization problem.In this formulation, each shape parameter corresponds to an individual gene within a chromosome's bit string, as shown in Fig 5.In this representation, when a gene is set to 1, assign a value to the corresponding shape parameter, and when it's set to 0, do not assign a value.If the shape parameters are expected to fall within the interval [a, b], they are determined within this range (a, b).So that the initial population consists of K individuals, each having a gene length of L. These genes are randomly initialized with 0s and 1s.It is vital to notice that the corner points are chosen prior to establishing the first population.The goal of this strategy is to keep these essential locations since they play an important function in forming the contours of the desired forms.
In order to find the value of parameter, the fitness function denoted as S i will calculate as the squared sums of the distances between P i,j 's and their corresponding parametric points on the curve as follows: To achieve the best fit of the curve to the given data, such values for the parameters ω i are essential that minimize the sums S i .GA is employed to optimize these values for the fitted curve.A random population for ω i is considered to initialize this optimization process.Therefore, iteratively applying optimization operations to this collection leads us to the optimal values of ω i .

Curve fitting
The identification of corner points initiates the division of the image boundary into smaller segments.Spline Interpolation outlined in Section 2 has been applied to estimate each segment of the boundary.The spline involves a parameter ω i , in its description.Initially, the values of ω i chosen randomly.Once an initial estimation for the segment is derived, GA is executed to determine the optimal values of ω i .It plays a decisive role in obtaining improved approximations leading to optimal solutions.

Breaking segment
In certain instances, the iterative refinement process may not yield a sufficiently satisfactory best fit for specific segments.In such situations, divide the segment into even smaller ones at locations when the gap between the boundary and the parametric curve surpasses a pre-established threshold.These designated points are referred to as intermediate points.For each of The gap between the boundary and the parametric curve is frequently represented as the squared distance between each point of a digitalized curve and its corresponding point on a parametric curve [17,18].However, this work uses the technique described in [19] to calculate the distance between the board and the parametric curve.This approach defined the distance (d) between a point P i,j on the digitized curve and its corresponding parametric point P*(z i,j ) on the curve as the largest difference between the abscissas or ordinates of under discussion points.

Algorithm
The entire process of computing the desired manipulation of the outline, the optimal QTBspline curve, can be condensed into the following algorithm.3. Corner Identification: Detect corners points from the boundary using the method described in Section 5.2.
4. Curve Fitting: Fit curves to the detected corners using the proposed QTB-Spline.
5. Optimization: Use GA to get the best optimal value of the parameters ω i .
6. Termination: If the curve, achieved in Step 4, is optimal then STOP and Go TO Step 7, otherwise, locate appropriate intermediate points as described in Section 5.5, and RETURN to Step 4.

7.
Output: Generate the vectorized representation of the image.

Experimental results
The curve fitting approach presented in Section 5 has been put into practice on various images.can be applied to Figs 10 and 11 for bit map images 'Turtle' and 'Hilal' respectively.The time required to apply this proposed method to different images is detailed in Table 2. Figs 12-14 illustrates the behavior of the fitness function when running the Genetic Algorithm repeatedly on images of Bat, Turtle and Hilal respectively.From these graphical visuals, it is evident that the lowest value of the cost function is attained after the 30th iteration.

Comparative & subsequent studies
The proposed scheme introduces several noteworthy advantages over its predecessors.Firstly, it exhibits enhanced computational efficiency compared to the methods outlined in references [3,[9][10][11][12], particularly evident in its ability to swiftly process vectorized outlines of images for planar objects with extensive datasets.Quantitative comparisons of computational time, as depicted in Tables 2 and 3, underscore this efficiency when placed side by side with existing techniques.In future the proposed method could extend to handle three-dimensional vectorization of shapes.The method would involve adapting the existing algorithm to incorporate depth information, enabling accurate representation of volumetric outlines in addition to planar contours.

Conclusions
A method is proposed to optimize the vectorization of raster image outlines.This technique employs the Genetic Algorithm to fine-tune a trigonometric spline to match the digital outline of the images.By initiating the search process from well-identified starting points (initially detected corner points), it achieves improved convergence results.The overall process encompasses several phases, including image outline extraction, corner point detection within the outlines, curve fitting, and the potential addition of extra knot points as necessary.The concept of the genetic algorithm is harnessed to optimize the shape parameters within the B-Spline description.This method ultimately yields optimal outcomes for approximating the vectorization of digital contours derived from generic shapes.It offers an optimal alignment while maintaining computational efficiency in the curve-fitting process.Importantly, the proposed algorithm operates autonomously and do not require human intervention.

Proposition 3 .
[Convex Hull Property (CHP)]: The QTB-Spline curve completely lies inside the convex hull produced (CHP) by the control polygon for {L k , U k , V k , L k+1 }.

Fig 2 .
Fig 2. The QTB-spline curves with different shape parameters.https://doi.org/10.1371/journal.pone.0307530.g002 ), X nþ1 k¼À 1 M k ðzÞ ¼ 1; for z 2 ½z 0 ; z n � and M k ðzÞ > 0; for all z: Consequently, the QTB-Spline curve is entirely held within the convex hull outlined by its control polygon, which is formed by {L k , U k , V k , L k+1 } as depicted in Fig 3(A) and 3(B).Proposition 4. [Variation Diminishing Property (VDP)]: Consider PðzÞ ¼ P 3 k¼0 M k ðzÞT * k , where z belongs to the interval [z 0 , z n ].For the QTB-Spline curve, almost any N-1 ultra dimensional plane intersects the curve only by following the control polygon set by the control points {L k , U k , V k , L k+1 }.

Fig 9 (
A) displays the original image (b) showcases the image's outline, (c) exhibits the corner points for bit map image 'Bat', and (d)-(h) reveal the fitted outlines without and with GA, (e) represents the first iteration and (h) shows the final iteration, instant of this, (f) and (g) shows the experimental results of fifth and tenth iteration, with a threshold of 3, utilizing Genetic Algorithms in conjunction with both corner and intermediate points.A similar description